The present invention relates to the field of disc drive data storage devices. More particularly, this invention relates to an adaptable cache for a disc drive.
An important device in any computer system is a data storage device. Computer systems have many different places where information, such as data and instructions, can be stored. One place for storing massive amounts of information is a disc drive. The disc drive has one or more discs, each with two surfaces on which data is stored. The surfaces are coated with a magnetizable medium that is magnetized in alternate directions to store the information. The coated surfaces are computer-readable media holding computer-readable data and computer-readable and computer-executable instructions. The discs are mounted on a hub of a spindle motor for rotation at an approximately constant high speed during the operation of the disc drive. An actuator assembly in the disc drive moves magnetic transducers, also called read/write heads or heads, to various locations relative to the discs while the discs are rotating, and electrical circuitry is used to write information to and read information from the media through the heads. Information is stored in the media of one or both of the surfaces of each disc. The disc drive also includes circuitry for encoding information written to the media and for decoding information read from the media. A microprocessor controls most operations of the disc drive, such as transmitting information read from the media back to a host computer and receiving information from the host computer for writing to the media.
In some disc drives, information is stored in a multiplicity of concentric circular tracks in the media on each disc. In other disc drives, information is stored in a single track that forms a continuous spiral in the media on each disc. The tracks are subdivided into sectors or blocks of media in which the information is stored. A read/write head is positioned over a track to write information to or read information from the track. Servo information is read from the track by the head, and a feedback control system determines a position error signal from the servo information. If the head is not in a correct position, it is moved to a desired position over the track in response to the position error signal. Once the operation is complete, the head may be controlled to move to a new, target track, to write information to or read information from the target track.
Cache memories are used to improve the performance of disc drives. A cache memory is typically located within a disc controller which controls the operation of the disc drive. The disc controller is coupled to a host computer through a bus. The disc controller passes information back and forth between the discs and the host computer in response to commands generated by the host computer. The commands cause the disc controller to initiate read and write operations. Each command includes a starting address, a block length of a number of blocks of information to be retrieved from the discs, and a command type, such as a read or a write. For example, after the disc controller receives a read command, it retrieves the required number of blocks of information from the discs beginning at the starting address.
After the information has been retrieved, the disc drive controller passes the information back to the host computer. The cache memory improves the performance of the disc drive by reducing the number of times the disc controller must go to the discs to retrieve information. The cache memory stores the most recently accessed information in a random access memory (RAM). When the host computer runs a particular software application, input/output patterns in the information seen by the disc controller tend to repeat. Therefore, there is a good chance that information obtained from the discs will be retrieved again. When the host computer requests the retrieval of information that is in the cache memory, the disc controller does not have to retrieve the information from the discs, but can retrieve it directly from the cache memory. The cache memory has a much faster access time than the discs, so retrieving the information directly from the cache memory substantially reduces the access time seen by the host computer.
The cache memory includes a cache buffer to store bytes of information and a cache table. The cache table maintains a list of the information present in the cache buffer by recording the starting addresses of the information retrieved from the discs. When the disc controller receives a write instruction that corresponds to addresses present in the cache memory, it updates the cache table such that it no longer indicates the information is present within the buffer. This prevents old information from being read from the cache buffer.
When the disc controller receives a read command, it refers to the cache table to determine whether the requested information is present in the cache buffer. If the information is not present in the cache buffer the event is called a cache miss, and the disc controller retrieves the information from the discs and relays it to the host computer. The disc controller also loads the information into the cache buffer and updates the cache table. A cache hit occurs when the information requested by the host computer is present in the cache buffer. In this situation, the disc controller retrieves the information directly from the cache buffer and transmits it to the host computer. The ratio of cache hits to cache misses is a measure of cache memory performance. The higher the ratio of cache hits to cache misses is, the better the cache memory is performing.
In a multi-segment cache memory, the cache buffer is divided into segments. The number of segments in the cache buffer is known as the segmentation level. By segmenting the cache buffer, the disc controller can perform look ahead operations by retrieving excess blocks of information to fill an entire segment. Because memory operations tend to form repetitive and often predictable patterns, the host computer may next request information from consecutive blocks. The segmentation level determines the number of blocks of information stored in each segment, and therefore determines the number of excess blocks retrieved. The greater the segmentation level, the smaller the number of blocks stored in each segment. Performance of the cache memory may be improved by adjusting the segmentation level.
A segmentation level that provides the best available performance depends upon the host computer. Different host computers run on different operating systems, and will retrieve information from the discs in different patterns. A segmentation level that performs well for one operating system may perform poorly for another operating system. In conventional disc drives the segmentation level for a cache memory is selected based on laboratory experiments before the disc drive is sold. However, often the operating system that the disc drive is to work with is unknown, and the segmentation level selected in the laboratory may not result in the best possible performance of the cache memory. There remains a need for methods of operating a disc drive, and in particular methods of selecting a segmentation level for a cache memory in the disc drive, that result in the best possible performance of the cache memory with any operating system that it might work with.
According to one embodiment of the present invention a disc controller in a disc drive includes a cache memory and a control circuit. The control circuit is configured to identify an operating system of a host computer coupled to the disc drive, select a segmentation level for the cache memory based on the identified operating system, and store information in the cache memory according to the segmentation level. According to another embodiment of the present invention a cache memory in a disc drive is operated by identifying an operating system of a host computer coupled to the disc drive, selecting a segmentation level for the cache memory based on the identified operating system, and storing information in the cache memory according to the segmentation level. The operating system is identified by reading a partition type from a master boot record stored in a disc in the disc drive.
Advantageously, the embodiments of the present invention provide for a selection of a segmentation level for the cache memory that is particularly suited for the operating system of the host computer. This results in better ratios of cache hits to cache misses as information is retrieved from the disc drive, and reduces the number of times that information must be read from discs in the disc drive. The selection of the segmentation level best suited to the operating system thereby improves the performance of the disc drive over disc drives that do not adapt the segmentation level to the operating system of the host computer.